#pragma once 

#include <list>
#include <stdint.h>
#include <memory>

using namespace std;

class WriteObject {
public:
    streamsize start; 
    streamsize len; 
    shared_ptr<char> buff;
};

class ConnWriter {
public:
    int fd;
private:
    bool isClosing = false;
    list<shared_ptr<WriteObject>> objs;
public:
    void OnWriteable();
    void LingerClose(); // 延迟关闭
    void EntireWrite(shared_ptr<char> buff, streamsize len); // 发送数据 

private:
    void EntireWriteWhenEmpty(shared_ptr<char> buff, streamsize len);
    void EntireWriteWhenNotEmpty(shared_ptr<char> buff, streamsize len);
    bool WriteFrontObj();
};